/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tpgen.grammar;

import java.util.Collection;

/**
 *
 * @author shanki
 */
public class NonTerminal implements Symbol {
    private String name;
    private Symbol symbol;
    
    public NonTerminal(String name) {
        this.name   = name;
    }
    
    public NonTerminal(String name, Symbol symbol) {
        this.name   = name;
        this.symbol = symbol;
    }

    @Override
    public boolean isUsable() {
        return symbol.isUsable();
    }    

    @Override
    public Collection<Symbol> expand(Context context) {
        return symbol.expand(context);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof NonTerminal) {
            NonTerminal other = (NonTerminal)obj;
            
            return  this.name.equals(other.name) &&
                    this.symbol.equals(other.symbol);
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 59 * hash + (this.symbol != null ? this.symbol.hashCode() : 0);
        return hash;
    }
    
    @Override
    public String toString() {
        return name;
    }    

    @Override
    public String toUserString() {
        return "";
    }

    public void setSymbol(Symbol symbol) {
        this.symbol = symbol;
    }
    
}
